package com.godyao.mall.pms.controller;

import java.util.Arrays;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.godyao.mall.pms.entity.SpuInfoDescEntity;
import com.godyao.mall.pms.service.SpuInfoDescService;
import com.godyao.mall.core.utils.PageUtils;
import com.godyao.mall.core.model.ResultMsg;



/**
 * spu信息介绍
 *
 * @author godyao
 * @email godyao0801@qq.com
 * @date 2022-04-19 14:42:40
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("pms/spuinfodesc")
public class SpuInfoDescController {
    
    private final SpuInfoDescService spuInfoDescService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public ResultMsg list(@RequestParam Map<String, Object> params){
        PageUtils page = spuInfoDescService.queryPage(params);

        return ResultMsg.resultSuccess(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{spuId}")
    public ResultMsg info(@PathVariable("spuId") Long spuId){
		SpuInfoDescEntity spuInfoDesc = spuInfoDescService.getById(spuId);

        return ResultMsg.resultSuccess(spuInfoDesc);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public ResultMsg save(@RequestBody SpuInfoDescEntity spuInfoDesc){
		spuInfoDescService.save(spuInfoDesc);

        return ResultMsg.resultSuccess("OK");
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public ResultMsg update(@RequestBody SpuInfoDescEntity spuInfoDesc){
		spuInfoDescService.updateById(spuInfoDesc);

        return ResultMsg.resultSuccess("OK");
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public ResultMsg delete(@RequestBody Long[] spuIds){
		spuInfoDescService.removeByIds(Arrays.asList(spuIds));

        return ResultMsg.resultSuccess("OK");
    }

}
